package cn.hfatec.shms.web;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * Created by Administrator on 2017-03-16.
 */
public class Rule {
    /**
     * BMI
     */
    public static Integer contrastBmi(Double first, Double second) {
        int value = 0;
        if (first >= 18 && first < 24) {
            if (second < 18 || second >= 24) {
                value = -1;
            }
        } else if (first >= 24 && first < 28) {
            if ((second >= 18 && second < first - 0.5) || (second >= 18 && second < 24)) {
                value = 1;
            } else if (second < 18 || second >= first) {
                value = -1;
            }
        } else if (first >= 28 && first < 36) {
            if ((second >= 18 && second < first - 1) || (second >= 18 && second < 28)) {
                value = 1;
            } else if (second < 18 || second >= first) {
                value = -1;
            }
        }
        return value;
    }

    /**
     * 心肺耐力MET
     */
    public static Integer contrastMet(Double first, Double second) {
        int value = 0;
        return value;
    }

    /**
     * 甘油三脂TG
     */
    public static Integer contrastTg(Double first, Double second) {
        int value = 0;
        if (first >= 0.45 && first < 2.3) {
            if (second >= 2.3) {
                value = -1;
            }
        } else if (first >= 2.3 && first < 5.6) {
            if (second >= 0.45 && second < 2.3) {
                value = 1;
            } else if (second >= first) {
                value = -1;
            }
        } else if (first >= 5.6 && first < 30) {
            if (second >= 0.45 && second < 5.6) {
                value = 1;
            } else if (second >= first) {
                value = -1;
            }
        }
        return value;
    }
    /**
     * 胆固醇（TC）
     */
    public static Integer contrastTc(Double first, Double second) {
        int value = 0;
        if (first >= 0 && first < 6.22) {
            if (second >= 6.22) {
                value = -1;
            }
        } else if (first >= 6.22 && first < 8.5) {
            if (second < first-1 || second < 6.22) {
                value = 1;
            } else if (second > first) {
                value = -1;
            }
        } else if (first >= 8.5 && first < 15) {
            if (second < first-1 || second < 8.5) {
                value = 1;
            } else if (second >= first) {
                value = -1;
            }
        }
        return value;
    }

    /**
     * 空腹血糖（FPG)
     */
    public static Integer contrastFpg(Double first, Double second) {
        int value = 0;
        if (first >= 3.9 && first < 6.11) {
            if (second >= 6.11 || second <3.9 ) {
                value = -1;
            }
        } else if (first >= 6.11 && first < 7.0) {
            if (second >=3.9 && second < 6.11) {
                value = 1;
            } else if (second >= 7.0 || second <3.9) {
                value = -1;
            }
        } else if (first >= 7.0 && first < 18) {
            if ((second <first-2 && second >= 3.9)||(second <7 && second >= 3.9)) {
                value = 1;
            } else if (second >= first || second <3.9) {
                value = -1;
            }
        }
        return value;
    }

    /**
     * 收缩压(SBP)
     */
    public static Integer contrastSbp(Double first, Double second) {
        int value = 0;
        if (first >= 90 && first < 140) {
            if (second >= 140 || second <90 ) {
                value = -1;
            }
        } else if (first >= 140 && first < 160) {
            if (second >=90 && second < 140) {
                value = 1;
            } else if (second >=160 || second <90) {
                value = -1;
            }
        } else if (first >= 160 && first < 200) {
            if (second <160 && second >= 90) {
                value = 1;
            } else if (second > first || second <90) {
                value = -1;
            }
        }
        return value;
    }
    /**
     * 舒张压(DBP)
     */
    public static Integer contrastDbp(Double first, Double second) {
        int value = 0;
        if (first >= 60 && first < 90) {
            if (second >= 90 || second <60 ) {
                value = -1;
            }
        } else if (first >= 90 && first < 100) {
            if (second >=60 && second < 90) {
                value = 1;
            } else if (second >=100 || second <60) {
                value = -1;
            }
        } else if (first >= 100 && first < 120) {
            if (second <100 && second >= 60) {
                value = 1;
            } else if (second > first || second <60) {
                value = -1;
            }
        }
        return value;
    }
}
